package com.gxc.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

@Aspect
@Configuration// 加入spring
@Order(2)
public class MyAspect1 {

    //
    @Around("within(com.gxc.service.*)")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("业务方法执行之前11111");
        System.out.println(proceedingJoinPoint.getSignature().getName()); 
        Object proceed = proceedingJoinPoint.proceed();
        System.out.println("业务方法执行之后11111");
        return proceed;
    }


//    // 前置后置都没有返回值
//    // 可以传入JoinPoint对象
//    @Before("within(com.gxc.service.*)")
//    public void before(JoinPoint joinPoint){
//        System.out.println("前置通知");
//        System.out.println(joinPoint.getSignature().getName());
//        System.out.println(joinPoint.getTarget());
//        System.out.println(joinPoint.getArgs());
//    }
//
//    @After("within(com.gxc.service.*)")
//    public void after(JoinPoint joinPoint){
//        System.out.println("后置方法======");
//
//    }
}
